<%@page import="txdnet.util.StaticMark"%>
<%@page import="cn.txdnet.txweb.utils.WebUtil"%>
<%@page import="cn.txdnet.txweb.utils.StringUtil"%>
<%@page import="txdnet.util.FileUtil"%>
<%@page import="java.io.File"%>
<%@page import="txdnet.util.Context"%>
<%@page import="txdnet.util.DataUtil"%>
<%@page contentType="application/javascript; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="true" buffer="16kb" session="false" autoFlush="true"%>
<%
    String files = DataUtil.getValid(request.getParameter("f"), "([\\.\\w]*?\\.(js)(,*?))+?", null);
    if (files == null || files.indexOf("..") >= 0) {
        response.sendError(400);
        return;
    }

    String[] files_arr = StringUtil.split(files, StaticMark.CHAR_COMMA);
    String rpt = WebUtil.WEB_APP_PATH.concat(File.separator).concat("js").concat(File.separator);
    StringBuilder sb = new StringBuilder();
    sb.append(";var def=def||{};def.ctx='").append(WebUtil.WEB_CTX_PATH).append("';");
    String tmp ;
    for (String f : files_arr) {
        if(StringUtil.isEmpty(f)){
            continue;
        }
        tmp = FileUtil.readStringByFile(rpt.concat(f));
        sb.append(tmp == null ? StaticMark.STR_EMPTY : tmp);
    }
    out.clear();out.print(sb);
%>